package com.duoshu.grj.sosoliuda.ui.view;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.duoshu.grj.sosoliuda.R;
import com.duoshu.grj.sosoliuda.SosoliudaApp;
import com.duoshu.grj.sosoliuda.model.ObjectRequest;
import com.duoshu.grj.sosoliuda.model.bean.FriendDetailResponse;
import com.duoshu.grj.sosoliuda.model.bean.FriendScoreResponse;
import com.duoshu.grj.sosoliuda.model.bean.MyFriendListResponse;
import com.duoshu.grj.sosoliuda.model.bean.RefundReasonItemBean;
import com.duoshu.grj.sosoliuda.model.util.HttpSubscriber;
import com.duoshu.grj.sosoliuda.ui.adapter.RefundReasonAdapter;
import com.duoshu.grj.sosoliuda.ui.user.LoginActivity;
import com.duoshu.grj.sosoliuda.ui.user.RegisterActivity;
import com.duoshu.grj.sosoliuda.utils.Constant;
import com.duoshu.grj.sosoliuda.utils.DataCleanManager;
import com.duoshu.grj.sosoliuda.utils.DateUtil;
import com.duoshu.grj.sosoliuda.utils.FrescoUtils;
import com.duoshu.grj.sosoliuda.utils.JumperUtils;
import com.duoshu.grj.sosoliuda.utils.LayoutManagerUtils;
import com.duoshu.grj.sosoliuda.utils.StringUtils;
import com.duoshu.grj.sosoliuda.utils.ToastUtils;
import com.facebook.drawee.view.SimpleDraweeView;
import com.zhy.autolayout.AutoLinearLayout;
import com.zhy.autolayout.utils.AutoUtils;

import org.simple.eventbus.EventBus;

import java.util.List;

/**
 * Author：GRJ
 * Date：2016/10/12 13:10
 * Email：pocketdog@163.com
 */

public class UserDialog extends Dialog {

    private Context mContext;
    private int type;

    public UserDialog(Context context) {
        super(context, R.style.dialog);
        this.mContext = context;
        moveUp();
    }

    public UserDialog(Context context, int sty) {
        super(context, R.style.dialog);
        this.mContext = context;
        moveUp1();
    }

    private void moveUp1() {
        Window dialogWindow = this.getWindow();
        dialogWindow.setGravity(Gravity.CENTER);
        //点击空白区域消失
        setCanceledOnTouchOutside(true);
        setCancelable(true);
    }

    private void moveUp() {
        Window dialogWindow = this.getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.y = -AutoUtils.getPercentHeightSize(250);
        dialogWindow.setAttributes(lp);
        //点击空白区域消失
        setCanceledOnTouchOutside(true);
        setCancelable(true);
    }

    public void showTextDialog(String content) {
        setContentView(R.layout.text_dialog);
        ImageView imageView = (ImageView) findViewById(R.id.close);
        TextView tv_title = (TextView) findViewById(R.id.content);
        tv_title.setText(content);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        show();
    }

    public void showModifyPwdDialog(String content, String btnStr) {
        setContentView(R.layout.single_btn_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView loginTv = (TextView) findViewById(R.id.login);
        TextView contentTv = (TextView) findViewById(R.id.content);
        contentTv.setText(content);
        loginTv.setText(btnStr);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                ((Activity) mContext).finish();
            }
        });
        loginTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                ((Activity) mContext).finish();
            }
        });
        show();
    }

    public void showLoginDialog() {
        setContentView(R.layout.single_btn_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView loginTv = (TextView) findViewById(R.id.login);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        loginTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                ((Activity) mContext).finish();
            }
        });
        show();
    }

    public void reSetPwdDialog(String content, String btnStr) {
        setContentView(R.layout.single_btn_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView loginTv = (TextView) findViewById(R.id.login);
        TextView contentTv = (TextView) findViewById(R.id.content);
        contentTv.setText(content);
        loginTv.setText(btnStr);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        loginTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        this.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                SosoliudaApp.closeLoginActivity();
                JumperUtils.JumpTo(((Activity) mContext), LoginActivity.class);
            }
        });
        show();
    }

    public void showRigsterDialog() {
        setContentView(R.layout.register_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView okTv = (TextView) findViewById(R.id.ok);
        TextView registerTv = (TextView) findViewById(R.id.register);
        View.OnClickListener onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        };
        closeIv.setOnClickListener(onClickListener);
        okTv.setOnClickListener(onClickListener);
        registerTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                JumperUtils.JumpTo(((Activity) mContext), RegisterActivity.class);
            }
        });
        show();
    }

    public void showShareDialog(String content, View.OnClickListener listener) {
        setContentView(R.layout.share2_dialog);
//        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView textView = (TextView) findViewById(R.id.content);
        textView.setText(content);
        TextView okTv = (TextView) findViewById(R.id.ok);
        TextView registerTv = (TextView) findViewById(R.id.register);
//        closeIv.setOnClickListener(listener);
        okTv.setOnClickListener(listener);
        registerTv.setOnClickListener(listener);
        show();
    }

    public void showChoiceDialog(String content, View.OnClickListener listener) {
        setContentView(R.layout.choice_btn_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        TextView textView = (TextView) findViewById(R.id.content);
        textView.setText(content);
        TextView cancel = (TextView) findViewById(R.id.cancel);
        TextView login = (TextView) findViewById(R.id.login);
//        closeIv.setOnClickListener(listener);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        login.setOnClickListener(listener);
        show();
    }

    public void showDoubleDialog(String content, String leftButton, String rightButton, View.OnClickListener listener) {
        setContentView(R.layout.choice_btn_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        TextView textView = (TextView) findViewById(R.id.content);
        textView.setText(content);
        TextView cancel = (TextView) findViewById(R.id.cancel);
        cancel.setText(leftButton);
        TextView login = (TextView) findViewById(R.id.login);
        login.setText(rightButton);
//        closeIv.setOnClickListener(listener);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        login.setOnClickListener(listener);
        show();
    }

    public void showDoubleDialog(String content, String leftButton, String rightButton, View.OnClickListener leftListener, View.OnClickListener rightListener) {
        setContentView(R.layout.choice_btn_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        TextView textView = (TextView) findViewById(R.id.content);
        textView.setText(content);
        TextView cancel = (TextView) findViewById(R.id.cancel);
        cancel.setText(leftButton);
        TextView login = (TextView) findViewById(R.id.login);
        login.setText(rightButton);
        cancel.setOnClickListener(leftListener);
        login.setOnClickListener(rightListener);
        show();
    }

    public void showShareDialog(String title, String content, String bt1, String bt2, View.OnClickListener listener) {
        setContentView(R.layout.share2_dialog);
//        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView textView = (TextView) findViewById(R.id.content);
        TextView tvtitle = (TextView) findViewById(R.id.dialog_title);
        textView.setText(content);
        tvtitle.setText(title);
        TextView okTv = (TextView) findViewById(R.id.ok);
        TextView registerTv = (TextView) findViewById(R.id.register);
        okTv.setText(bt1);
        registerTv.setText(bt2);
        okTv.setOnClickListener(listener);
        registerTv.setOnClickListener(listener);
        show();
    }

    public void showDeleteAddressDialog(View.OnClickListener listener) {
        setContentView(R.layout.delete_address_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView okTv = (TextView) findViewById(R.id.queding);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        okTv.setOnClickListener(listener);
        show();
    }

    public void cleanDataDialog(String content, String btnStr) {
        setContentView(R.layout.single_btn_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView loginTv = (TextView) findViewById(R.id.login);
        TextView contentTv = (TextView) findViewById(R.id.content);
        contentTv.setText(content);
        loginTv.setText(btnStr);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        loginTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                DataCleanManager.cleanAll(mContext);
                ToastUtils.toastShort("清除成功");
            }
        });
        show();
    }

    public void showEditCodeDialog() {
        setContentView(R.layout.edit_code_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView loginTv = (TextView) findViewById(R.id.sure);
        EditText editText = (EditText) findViewById(R.id.content);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        loginTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                showSingleButtonDialog("您输入的验证码有误，请重新输入", "确定");
            }
        });
        show();
    }

    public void showPasswordDialog(String content, String btnStr, View.OnClickListener onClickListener) {
        setContentView(R.layout.edit_pwd_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView loginTv = (TextView) findViewById(R.id.sure);
        EditText editText = (EditText) findViewById(R.id.edit_pwd);
        TextView tvContent = (TextView) findViewById(R.id.content);
        tvContent.setText(content);
        loginTv.setText(btnStr);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        loginTv.setOnClickListener(onClickListener);
        show();
    }

    public void showGroupDissolveDialog(String strContent, View.OnClickListener onClickListener) {
        setContentView(R.layout.dissolve_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        Button cancel = (Button) findViewById(R.id.cancel);
        Button dissolve = (Button) findViewById(R.id.dissolve);
        TextView content = (TextView) findViewById(R.id.content);
        content.setText(strContent);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        dissolve.setOnClickListener(onClickListener);
        show();
    }

    public void showSingleButtonDialog(String content, String btnStr) {
        setContentView(R.layout.single_btn_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView loginTv = (TextView) findViewById(R.id.login);
        TextView contentTv = (TextView) findViewById(R.id.content);
        contentTv.setText(content);
        loginTv.setText(btnStr);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        loginTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        show();
    }

    public void showSingleButtonDialog(String content, String btnStr, View.OnClickListener onClickListener) {
        setContentView(R.layout.single_btn_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView loginTv = (TextView) findViewById(R.id.login);
        TextView contentTv = (TextView) findViewById(R.id.content);
        contentTv.setText(content);
        loginTv.setText(btnStr);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        loginTv.setOnClickListener(onClickListener);
        show();
    }

    public void showDynamicPublishDialog(View.OnClickListener onClickListener) {
        setContentView(R.layout.dynamic_publish_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView tv_dynamic_hong_bao = (TextView) findViewById(R.id.tv_dynamic_hong_bao);
        TextView tv_dynamic_normal = (TextView) findViewById(R.id.tv_dynamic_normal);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        tv_dynamic_hong_bao.setOnClickListener(onClickListener);
        tv_dynamic_normal.setOnClickListener(onClickListener);
        show();
    }

    public void showClearHistoryRecordDialog(View.OnClickListener onClickListener) {
        setContentView(R.layout.layout_clear_history_record_dialog);
        TextView tv_cancel = (TextView) findViewById(R.id.tv_cancel);
        TextView tv_ok = (TextView) findViewById(R.id.tv_ok);
        tv_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        tv_ok.setOnClickListener(onClickListener);
        show();
    }

    public void openSetImgDialog(View.OnClickListener onClickListener1, View.OnClickListener onClickListener2) {
        setContentView(R.layout.open_photo_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView takePhotoTv = (TextView) findViewById(R.id.take_photo);
        TextView choosePhotoTv = (TextView) findViewById(R.id.choose_photo);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        takePhotoTv.setOnClickListener(onClickListener1);
        choosePhotoTv.setOnClickListener(onClickListener2);
        show();
    }

    public void bindMobileExistDialog(View.OnClickListener onClickListener1, View.OnClickListener onClickListener2) {
        setContentView(R.layout.mobile_exist_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView leftBtn = (TextView) findViewById(R.id.left_btn);
        TextView rightBtn = (TextView) findViewById(R.id.right_btn);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        leftBtn.setOnClickListener(onClickListener1);
        rightBtn.setOnClickListener(onClickListener2);
        show();
    }

    public void showPayDialog() {
        setContentView(R.layout.pay_dialog);
//        setCanceledOnTouchOutside(false);
        show();
    }

    public void showPayOfFailureDialog() {
        setContentView(R.layout.pay_failure_dialog);
//        setCanceledOnTouchOutside(false);
        show();
    }

    public void showPayDialog(String content) {
        setContentView(R.layout.pay_dialog);
        TextView contentTv = (TextView) findViewById(R.id.tv_pay_sucess);
        contentTv.setText(content);
//        setCanceledOnTouchOutside(false);
        show();
    }

    /**
     * 订单弹窗显示
     *
     * @param content  提示内容
     * @param text     提示按钮操作
     * @param listener 监听
     * @return
     */
    public void showOrderDialog(String content, String text, View.OnClickListener listener) {
        setContentView(R.layout.delete_address_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView okTv = (TextView) findViewById(R.id.queding);
        TextView tvContent = (TextView) findViewById(R.id.content);
        okTv.setText(text);
        tvContent.setText(content);
        View.OnClickListener onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        };
        closeIv.setOnClickListener(onClickListener);
        okTv.setOnClickListener(listener);
        show();
    }

    public void showWalletPayDialog(String content, String text) {
        setContentView(R.layout.delete_address_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView okTv = (TextView) findViewById(R.id.queding);
        TextView tvContent = (TextView) findViewById(R.id.content);
        closeIv.setVisibility(View.INVISIBLE);
        okTv.setText(text);
        tvContent.setText(content);
        View.OnClickListener onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        };
        okTv.setOnClickListener(onClickListener);
        show();
    }

    public void showPaySuccessDialog(String content, String text, View.OnClickListener listener) {
        setContentView(R.layout.delete_address_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView okTv = (TextView) findViewById(R.id.queding);
        TextView tvContent = (TextView) findViewById(R.id.content);
        okTv.setText(text);
        tvContent.setText(content);
        closeIv.setOnClickListener(listener);
        okTv.setOnClickListener(listener);
        show();
    }


    public void showOrderSeleteDialog(Activity activity, List<RefundReasonItemBean> list, View.OnClickListener listener) {
        Window dialogWindow = this.getWindow();
        dialogWindow.setGravity(Gravity.CENTER);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.y = AutoUtils.getPercentHeightSize(80);
        dialogWindow.setAttributes(lp);
        setContentView(R.layout.cancel_order_dialog);
        findViewById(R.id.ll_bottom).setVisibility(View.GONE);
        RecyclerView recycler_view_reasons = (RecyclerView) findViewById(R.id.recycler_view_reasons);
        recycler_view_reasons.setHasFixedSize(true);
        recycler_view_reasons.setLayoutManager(LayoutManagerUtils.getLinearLayoutManager(mContext));
        RefundReasonAdapter refundReasonsAdapter = new RefundReasonAdapter(list, activity, listener);
        recycler_view_reasons.setAdapter(refundReasonsAdapter);
        show();
    }

    public RefundReasonAdapter refundReasonsAdapter;

    public void showOrderDialogOfCancelOrder(Activity activity, List<RefundReasonItemBean> list, View.OnClickListener listener, View.OnClickListener itemListener) {
        Window dialogWindow = this.getWindow();
        dialogWindow.setGravity(Gravity.CENTER);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.y = AutoUtils.getPercentHeightSize(80);
        dialogWindow.setAttributes(lp);
        setContentView(R.layout.cancel_order_dialog);
        RecyclerView recycler_view_reasons = (RecyclerView) findViewById(R.id.recycler_view_reasons);
        findViewById(R.id.ll_bottom).setVisibility(View.VISIBLE);
        TextView tv_yes = (TextView) findViewById(R.id.tv_yes);
        TextView tv_no = (TextView) findViewById(R.id.tv_no);

        recycler_view_reasons.setHasFixedSize(true);
        recycler_view_reasons.setLayoutManager(LayoutManagerUtils.getLinearLayoutManager(mContext));

        refundReasonsAdapter = new RefundReasonAdapter(list, activity, itemListener);
        recycler_view_reasons.setAdapter(refundReasonsAdapter);

        View.OnClickListener onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        };
        tv_no.setOnClickListener(onClickListener);
        tv_yes.setOnClickListener(listener);

        show();
    }

    public void showAskforCanclePreSellDialog(Activity activity, View.OnClickListener listener) {
        Window dialogWindow = this.getWindow();
        dialogWindow.setGravity(Gravity.BOTTOM);

        setContentView(R.layout.cancel_presell_order_dialog);
        findViewById(R.id.ll_bottom).setVisibility(View.VISIBLE);
        TextView tv_yes = (TextView) findViewById(R.id.tv_yes);
        TextView tv_no = (TextView) findViewById(R.id.tv_no);
        ImageView img_cancle = (ImageView) findViewById(R.id.img_close);

        View.OnClickListener onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        };
        tv_no.setOnClickListener(onClickListener);
        img_cancle.setOnClickListener(onClickListener);
        tv_yes.setOnClickListener(listener);

        show();

        WindowManager.LayoutParams layoutParams = dialogWindow.getAttributes();
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
        dialogWindow.getDecorView().setPadding(0, 0, 0, 0);
        dialogWindow.setAttributes(layoutParams);
    }


    /**
     * @param content
     * @param text     提示内容
     * @param listener 关闭按钮与确认按钮的监听
     */
    public void showSoosoaPrice(String content, String text, View.OnClickListener listener) {
        setContentView(R.layout.delete_address_dialog);
        setCanceledOnTouchOutside(false);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView okTv = (TextView) findViewById(R.id.queding);
        TextView tvContent = (TextView) findViewById(R.id.content);
        okTv.setText(text);
        tvContent.setText(content);
        closeIv.setOnClickListener(listener);
        okTv.setOnClickListener(listener);
        show();
    }

    public static void showDaShangDialog(final Activity activity, final String userId
            , final String topDate, final int position) {
        LayoutInflater inflater = LayoutInflater.from(activity);
        final LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.friends_send_popupwindow, null);

        LoadingFrameView loading = (LoadingFrameView) layout.findViewById(R.id.loading_fv);
        loading.setContainerShown(true, 0);
        final SimpleDraweeView user_icon = (SimpleDraweeView) layout.findViewById(R.id.dashang_icon);
        final SimpleDraweeView user_icon1 = (SimpleDraweeView) layout.findViewById(R.id.dashang_icon1);
        final TextView user_name = (TextView) layout.findViewById(R.id.user_name);
        final TextView dashang_step = (TextView) layout.findViewById(R.id.dashang_step);
        final TextView dashang_kilo = (TextView) layout.findViewById(R.id.dashang_kilometer);
        final TextView dashang_cal = (TextView) layout.findViewById(R.id.dashang_cal);
        final TextView dashang_max = (TextView) layout.findViewById(R.id.dashang_max);
        final TextView dashang_left_gold = (TextView) layout.findViewById(R.id.dashang_left_gold);
        ImageView rank_iv = (ImageView) layout.findViewById(R.id.rank_iv);
        ImageView closeIv = (ImageView) layout.findViewById(R.id.close);
        final EditText editText = (EditText) layout.findViewById(R.id.dashang_edit);
        Button sureButton = (Button) layout.findViewById(R.id.dashang_btn);
        LinearLayout ll_close = (LinearLayout) layout.findViewById(R.id.ll_close);

        final String dashangMax = SosoliudaApp.getACache().getAsString(Constant.FriendTag.DASHANG_MAX);

        switch (position) {
            case 0:
                rank_iv.setImageResource(R.drawable.hy_badge_a);
                break;
            case 1:
                rank_iv.setImageResource(R.drawable.hy_badge_b);
                break;
            case 2:
                rank_iv.setImageResource(R.drawable.hy_badge_c);
                break;
        }

        final AlertDialog dialog = new AlertDialog.Builder(activity, R.style.dialog).create();
//        Window dialogWindow = dialog.getWindow();
//        dialogWindow.setGravity(Gravity.CENTER);
//        dialog.show();
//        dialogWindow.setContentView(layout);
//        dialogWindow.clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        ObjectRequest.getInstance().getFriendDetail(userId, topDate
                , SosoliudaApp.getACache().getAsString(Constant.ACacheTag.USER_ID))
                .subscribe(new HttpSubscriber<FriendDetailResponse>() {
                    @Override
                    public void onNext(FriendDetailResponse friendDetailResponse) {

                        if (TextUtils.isEmpty(friendDetailResponse.get_friends_details.avatar)) {
                            user_icon.setVisibility(View.VISIBLE);
                            user_icon1.setVisibility(View.GONE);
                            user_icon.setImageResource(R.drawable.wd_n);
                        } else {
                            if (friendDetailResponse.get_friends_details.sex.equals("女")) {
                                user_icon.setVisibility(View.VISIBLE);
                                user_icon1.setVisibility(View.GONE);
                                FrescoUtils.loadImage(friendDetailResponse.get_friends_details.avatar, user_icon);
                            } else {
                                user_icon.setVisibility(View.GONE);
                                user_icon1.setVisibility(View.VISIBLE);
                                FrescoUtils.loadImage(friendDetailResponse.get_friends_details.avatar, user_icon1);
                            }
                        }
                        user_name.setText(friendDetailResponse.get_friends_details.nick);
                        dashang_step.setText(friendDetailResponse.get_friends_details.step_count);
                        dashang_kilo.setText(String.valueOf(friendDetailResponse.get_friends_details.distance));
                        dashang_cal.setText(friendDetailResponse.get_friends_details.calorie);
                        if (!TextUtils.isEmpty(dashangMax))
                            dashang_max.setText((Integer.valueOf(dashangMax) / 10000) + "");
                        SosoliudaApp.getACache().put(Constant.FriendTag.GOLD_SELF, friendDetailResponse.get_friends_details.amount);
                        dashang_left_gold.setText(StringUtils.getAllMoneyStr((int) Double.parseDouble(friendDetailResponse.get_friends_details.amount), false));
                        Window dialogWindow = dialog.getWindow();
                        dialogWindow.setGravity(Gravity.CENTER);
                        dialog.show();
                        dialogWindow.setContentView(layout);
                        dialogWindow.clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                        ToastUtils.toastShort("获取数据失败，请稍后重试");
                        dialog.dismiss();
                    }
                });
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        ll_close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        sureButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String goldNum = editText.getText().toString().trim();
                if (TextUtils.isEmpty(goldNum)) {
                    ToastUtils.toastShort("请输入您要打赏的钱脚忙数量");
                    return;
                }
//                if (goldNum.equals("0")) {
//                    ToastUtils.toastShort("打赏积分不能为0");
//                    return;
//                }
//                if (!TextUtils.isEmpty(dashangMax)
//                        && Integer.valueOf(goldNum) > Integer.valueOf(dashangMax)) {
//                    ToastUtils.toastShort("打赏积分不能大于最高限额");
//                    return;
//                }
//                String goldSelf = SosoliudaApp.getACache().getAsString(Constant.FriendTag.GOLD_SELF);
//                if (Integer.valueOf(goldNum) > Double.valueOf(goldSelf)) {
//                    ToastUtils.toastShort("打赏积分不能高于自己余额");
//                    return;
//                }
                ObjectRequest.getInstance().giveFriendsScore(userId, topDate, goldNum)
                        .subscribe(new HttpSubscriber<FriendScoreResponse>() {
                            @Override
                            public void onNext(FriendScoreResponse friendScoreResponse) {
                                ToastUtils.toastShort(friendScoreResponse.msg);
                                if (friendScoreResponse.code.equals("0")) {
                                    dialog.dismiss();
                                }
                            }

                            @Override
                            public void onError(Throwable e) {
                                super.onError(e);
                                ToastUtils.toastShort("打赏失败，请稍后重试");
                                dialog.dismiss();
                            }
                        });
            }
        });

    }

    //计步异常弹框
    public void showStepDialog(String content, String btnStr, View.OnClickListener listener) {
        setContentView(R.layout.single_btn_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView loginTv = (TextView) findViewById(R.id.login);
        TextView contentTv = (TextView) findViewById(R.id.content);
        contentTv.setText(content);
        loginTv.setText(btnStr);
        closeIv.setVisibility(View.INVISIBLE);
        loginTv.setOnClickListener(listener);
        Window dialogWindow = getWindow();
        dialogWindow.getAttributes().y = 0;
        dialogWindow.setGravity(Gravity.CENTER);
        show();
    }

    public void setStepDialog(String content, String btnStr, String btnStr2, View.OnClickListener listener) {
        setContentView(R.layout.register_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView okTv = (TextView) findViewById(R.id.ok);
        TextView contentTv = (TextView) findViewById(R.id.content);
        TextView registerTv = (TextView) findViewById(R.id.register);
        contentTv.setText(content);
        okTv.setText(btnStr);
        registerTv.setText(btnStr2);
        closeIv.setOnClickListener(listener);
        okTv.setOnClickListener(listener);
        registerTv.setOnClickListener(listener);
        show();
    }

    public void showQJMSuccessDialog(String qjmType, int qjmNum) {
        setContentView(R.layout.get_qjm_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView okTv = (TextView) findViewById(R.id.queding);
        TextView mQjmType = (TextView) findViewById(R.id.qjm_style);
        TextView mQjmNum = (TextView) findViewById(R.id.qjm_num);
        mQjmType.setText(qjmType);
        mQjmNum.setText(String.valueOf(qjmNum));
        View.OnClickListener onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        };
        closeIv.setOnClickListener(onClickListener);
        okTv.setOnClickListener(onClickListener);
        show();
    }


    public void showUserCardDialog(String name, String shareName, View.OnClickListener listener) {
        setContentView(R.layout.share2_dialog);
        //        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView textView = (TextView) findViewById(R.id.content);
        TextView title = (TextView) findViewById(R.id.dialog_title);
        title.setText("将名片发送给:" + name);
        if (shareName.length() > 6) {
            textView.setText("确认发送[" + shareName.substring(0, 6) + "...]的名片吗？");
        } else {
            textView.setText("确认发送[" + shareName + "]的名片吗？");
        }
        TextView okTv = (TextView) findViewById(R.id.ok);
        TextView registerTv = (TextView) findViewById(R.id.register);
        //        closeIv.setOnClickListener(listener);
        okTv.setOnClickListener(listener);
        registerTv.setOnClickListener(listener);
        show();
    }

    //商品详情页更多弹框
    public void showGoodDialog(int i) {
        //i=0 商品 i=1 租赁
        Window dialogWindow = this.getWindow();
        dialogWindow.setGravity(Gravity.RIGHT | Gravity.TOP);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.y = AutoUtils.getPercentHeightSize(80);
        dialogWindow.setAttributes(lp);
        if (i == 0) {
            setContentView(R.layout.popup_menu_new);
        } else {
            setContentView(R.layout.popup_menu);
        }
        AutoLinearLayout homell = (AutoLinearLayout) findViewById(R.id.good_home);
        AutoLinearLayout sharell = (AutoLinearLayout) findViewById(R.id.good_share);
        AutoLinearLayout likell = (AutoLinearLayout) findViewById(R.id.good_like);
        AutoLinearLayout jilull = (AutoLinearLayout) findViewById(R.id.good_jilu);
        if (i == 0) {
            AutoLinearLayout libao = (AutoLinearLayout) findViewById(R.id.good_libao);
            libao.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    EventBus.getDefault().post(5, Constant.EventBusTag.GOOD_DIALOG_CLICK);
                    dismiss();
                }
            });
        }
        ToastUtils.resetTime();
        View.OnClickListener onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                switch (v.getId()) {
                    case R.id.good_home:
                        //首页
                        EventBus.getDefault().post(1, Constant.EventBusTag.GOOD_DIALOG_CLICK);
                        break;
                    case R.id.good_share:
                        //分享
                        if (ToastUtils.isFastClick())
                            return;
                        EventBus.getDefault().post(2, Constant.EventBusTag.GOOD_DIALOG_CLICK);
                        break;
                    case R.id.good_like:
                        //我的关注
                        EventBus.getDefault().post(3, Constant.EventBusTag.GOOD_DIALOG_CLICK);
                        break;
                    case R.id.good_jilu:
                        //浏览记录
                        EventBus.getDefault().post(4, Constant.EventBusTag.GOOD_DIALOG_CLICK);
                        break;
                }
            }
        };
        homell.setOnClickListener(onClickListener);
        sharell.setOnClickListener(onClickListener);
        likell.setOnClickListener(onClickListener);
        jilull.setOnClickListener(onClickListener);

        show();
    }

    /**
     * 主题详情弹框
     *
     * @param type
     * @param status 1==主题详情  2==子主题详情
     */
    public void showTopicDialog(final int type, final int status) {

        Window dialogWindow = this.getWindow();
        dialogWindow.setGravity(Gravity.RIGHT | Gravity.TOP);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.y = AutoUtils.getPercentHeightSize(80);

        setContentView(R.layout.popup_menu_topic);
        AutoLinearLayout topic_share = (AutoLinearLayout) findViewById(R.id.topic_share);
        AutoLinearLayout topic_edit = (AutoLinearLayout) findViewById(R.id.topic_edit);
        AutoLinearLayout topic_delete = (AutoLinearLayout) findViewById(R.id.topic_delete);
        AutoLinearLayout topic_add_child = (AutoLinearLayout) findViewById(R.id.topic_add_child);
        AutoLinearLayout topic_delete_comment = (AutoLinearLayout) findViewById(R.id.topic_delete_comment);
        AutoLinearLayout topic_comment = (AutoLinearLayout) findViewById(R.id.topic_comment);

        TextView tv_share = (TextView) findViewById(R.id.tv_share);
        TextView tv_edit = (TextView) findViewById(R.id.tv_edit);
        TextView tv_delete = (TextView) findViewById(R.id.tv_delete);
        TextView tv_add_child = (TextView) findViewById(R.id.tv_add_child);
        ImageView iv_share = (ImageView) findViewById(R.id.iv_share);
        ImageView iv_edit = (ImageView) findViewById(R.id.iv_edit);
        ImageView iv_delete = (ImageView) findViewById(R.id.iv_delete);
        ImageView iv_child = (ImageView) findViewById(R.id.iv_child);


        AutoLinearLayout linear_root = (AutoLinearLayout) findViewById(R.id.linear_root);

        switch (type) {
            case 1:
                linear_root.setBackgroundResource(R.drawable.qz_popup_01);
                break;
            case 2:
                linear_root.setBackgroundResource(R.drawable.qz_popup2);
                topic_edit.setVisibility(View.GONE);
                topic_delete.setVisibility(View.GONE);
                topic_share.setVisibility(View.VISIBLE);
                topic_add_child.setVisibility(View.VISIBLE);
                break;
            case 3:
                linear_root.setBackgroundResource(R.drawable.qz_popup_03);
                topic_add_child.setVisibility(View.GONE);
                topic_edit.setVisibility(View.VISIBLE);
                topic_delete.setVisibility(View.VISIBLE);
                topic_share.setVisibility(View.VISIBLE);
                break;
            case 4:
                topic_add_child.setVisibility(View.VISIBLE);
                topic_edit.setVisibility(View.VISIBLE);
                topic_delete.setVisibility(View.VISIBLE);
                topic_share.setVisibility(View.VISIBLE);
                linear_root.setBackgroundResource(R.drawable.good_popup);
                break;
            case 5://黑色背景两个选项，编辑，删除
                linear_root.setBackgroundResource(R.drawable.icon_246_71);
                topic_edit.setVisibility(View.VISIBLE);
                topic_delete.setVisibility(View.VISIBLE);
                topic_share.setVisibility(View.GONE);
                topic_add_child.setVisibility(View.GONE);
                iv_delete.setVisibility(View.GONE);
                iv_edit.setVisibility(View.GONE);
                tv_share.setTextColor(Color.WHITE);
                tv_edit.setTextColor(Color.WHITE);
                tv_delete.setTextColor(Color.WHITE);
                tv_add_child.setTextColor(Color.WHITE);
                lp.dimAmount = 0f;
                break;

            case 6://黑色背景两个选项，删除，回复
                linear_root.setBackgroundResource(R.drawable.icon_246_71);
                topic_edit.setVisibility(View.GONE);
                topic_delete.setVisibility(View.GONE);
                topic_share.setVisibility(View.GONE);
                topic_add_child.setVisibility(View.GONE);
                topic_delete_comment.setVisibility(View.VISIBLE);
                topic_comment.setVisibility(View.VISIBLE);

                tv_share.setTextColor(Color.WHITE);
                tv_edit.setTextColor(Color.WHITE);
                tv_delete.setTextColor(Color.WHITE);
                tv_add_child.setTextColor(Color.WHITE);
                lp.dimAmount = 0f;
                break;

        }
        ToastUtils.resetTime();
        View.OnClickListener onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                switch (v.getId()) {
                    case R.id.topic_share:
                        //分享
                        if (status == 1) {
                            EventBus.getDefault().post(1, Constant.TOPIC_MORE);
                        } else {
                            EventBus.getDefault().post(1, Constant.TOPIC_MORE_TYPE);
                        }
                        break;
                    case R.id.topic_edit:
                        //编辑
                        if (ToastUtils.isFastClick())
                            return;
                        EventBus.getDefault().post(2, Constant.TOPIC_MORE_TYPE);

//                        if (status==1){
//                            EventBus.getDefault().post(2, Constant.TOPIC_MORE);
//                        }else{
//                            EventBus.getDefault().post(2, Constant.TOPIC_MORE_TYPE);
//                        }
                        break;
                    case R.id.topic_delete:
                        //删除
                        if (type == 6) {

                        } else {
                            EventBus.getDefault().post(3, Constant.TOPIC_MORE_TYPE);
                        }

//                        if (status==1){
//                            EventBus.getDefault().post(3, Constant.TOPIC_MORE);
//                        }else{
//                            EventBus.getDefault().post(3, Constant.TOPIC_MORE_TYPE);
//                        }
                        break;
                    case R.id.topic_add_child:
                        //添加子主题
                        if (status == 1) {
                            EventBus.getDefault().post(4, Constant.TOPIC_MORE);
                        } else {
                            EventBus.getDefault().post(4, Constant.TOPIC_MORE_TYPE);
                        }
                        break;
                    case R.id.topic_delete_comment:
                        //删除评论
                        EventBus.getDefault().post(5, Constant.TOPIC_MORE_TYPE);
                        break;
                    case R.id.topic_comment:
                        //评论
                        EventBus.getDefault().post(6, Constant.TOPIC_MORE_TYPE);
                        break;
                }
            }
        };
        topic_share.setOnClickListener(onClickListener);
        topic_edit.setOnClickListener(onClickListener);
        topic_delete.setOnClickListener(onClickListener);
        topic_add_child.setOnClickListener(onClickListener);
        dialogWindow.setAttributes(lp);
        show();
    }


    /**
     * 主题详情弹框
     *
     * @param type
     */
    public void showTopicDialog2(final int type) {

        Window dialogWindow = this.getWindow();
        dialogWindow.setGravity(Gravity.RIGHT | Gravity.TOP);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.y = AutoUtils.getPercentHeightSize(80);
        lp.dimAmount = 0f;
        setContentView(R.layout.popup_menu_topic2);
        AutoLinearLayout topic_edit = (AutoLinearLayout) findViewById(R.id.topic_edit);
        AutoLinearLayout topic_delete = (AutoLinearLayout) findViewById(R.id.topic_delete);
        AutoLinearLayout topic_delete_comment = (AutoLinearLayout) findViewById(R.id.topic_delete_comment);
        AutoLinearLayout topic_comment = (AutoLinearLayout) findViewById(R.id.topic_comment);

        TextView tv_edit = (TextView) findViewById(R.id.tv_edit);
        TextView tv_delete = (TextView) findViewById(R.id.tv_delete);


        AutoLinearLayout linear_root = (AutoLinearLayout) findViewById(R.id.linear_root);

        linear_root.setBackgroundResource(R.drawable.icon_246_71);
        switch (type) {
            case 1:
                topic_edit.setVisibility(View.VISIBLE);
                topic_delete.setVisibility(View.VISIBLE);

                topic_delete_comment.setVisibility(View.GONE);

                topic_comment.setVisibility(View.GONE);

                break;
            case 2:
                topic_edit.setVisibility(View.GONE);
                topic_delete.setVisibility(View.GONE);

                topic_delete_comment.setVisibility(View.VISIBLE);

                topic_comment.setVisibility(View.VISIBLE);

                break;
        }
        ToastUtils.resetTime();
        View.OnClickListener onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                switch (v.getId()) {
                    case R.id.topic_edit:
                        //编辑
                        if (ToastUtils.isFastClick())
                            return;
                        EventBus.getDefault().post(2, Constant.TOPIC_MORE_TYPE);

//                        if (status==1){
//                            EventBus.getDefault().post(2, Constant.TOPIC_MORE);
//                        }else{
//                            EventBus.getDefault().post(2, Constant.TOPIC_MORE_TYPE);
//                        }
                        break;
                    case R.id.topic_delete:
                        EventBus.getDefault().post(3, Constant.TOPIC_MORE_TYPE);

//                        if (status==1){
//                            EventBus.getDefault().post(3, Constant.TOPIC_MORE);
//                        }else{
//                            EventBus.getDefault().post(3, Constant.TOPIC_MORE_TYPE);
//                        }
                        break;
                    case R.id.topic_delete_comment:
                        //删除评论
                        EventBus.getDefault().post(5, Constant.TOPIC_MORE_TYPE);
                        break;
                    case R.id.topic_comment:
                        //评论
                        EventBus.getDefault().post(6, Constant.TOPIC_MORE_TYPE);
                        break;
                }
            }
        };
        topic_edit.setOnClickListener(onClickListener);
        topic_delete.setOnClickListener(onClickListener);
        topic_delete_comment.setOnClickListener(onClickListener);
        topic_comment.setOnClickListener(onClickListener);

        dialogWindow.setAttributes(lp);
        show();
    }


    public void hintDialog(String content, String btnStr) {
        setContentView(R.layout.single_btn_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView loginTv = (TextView) findViewById(R.id.login);
        TextView contentTv = (TextView) findViewById(R.id.content);
        contentTv.setText(content);
        loginTv.setText(btnStr);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        loginTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        show();
    }

    public void hintDialog2(String content, String btnStr,View.OnClickListener l) {
        setContentView(R.layout.single_btn_dialog);
        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView loginTv = (TextView) findViewById(R.id.login);
        TextView contentTv = (TextView) findViewById(R.id.content);
        contentTv.setText(content);
        loginTv.setText(btnStr);
        closeIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        loginTv.setOnClickListener(l);
        show();
    }

    public static void showDialog(Activity context) {
        View view = LayoutInflater.from(context).inflate(R.layout.photo_choose_dialog,
                null);
        Button getMoney = (Button) view.findViewById(R.id.btn_get);
        Button sendMOney = (Button) view.findViewById(R.id.btn_send);
        Button btnCancel = (Button) view.findViewById(R.id.btn_cancel);
        final Dialog dialog = new Dialog(context, R.style.transparentFrameWindowStyle);
        dialog.setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        Window window = dialog.getWindow();
        // 设置显示动画
//        window.setWindowAnimations(R.style.main_menu_animstyle);
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.x = 0;
        wl.y = context.getWindowManager().getDefaultDisplay().getHeight();
        // 以下这两句是为了保证按钮可以水平满屏
        wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
        wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;

        getMoney.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(0, "CHECK_MONEY_LIST");
                dialog.dismiss();
            }
        });
        sendMOney.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(1, "CHECK_MONEY_LIST");
                dialog.dismiss();
            }
        });
        btnCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(2, "CHECK_MONEY_LIST");
                dialog.dismiss();
            }
        });

        // 设置显示位置
        dialog.onWindowAttributesChanged(wl);
        // 设置点击外围解散
        dialog.setCanceledOnTouchOutside(true);
        dialog.show();
    }

    public static void showUserDialog(Activity context) {
        View view = LayoutInflater.from(context).inflate(R.layout.user_choose_dialog,
                null);
        AutoLinearLayout al_chat = (AutoLinearLayout) view.findViewById(R.id.al_chat);
        AutoLinearLayout al_delete = (AutoLinearLayout) view.findViewById(R.id.al_delete);
        final Dialog dialog = new Dialog(context, R.style.transparentFrameWindowStyle);
        dialog.setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        Window window = dialog.getWindow();
        // 设置显示动画
//        window.setWindowAnimations(R.style.main_menu_animstyle);
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.x = 0;
        wl.y = context.getWindowManager().getDefaultDisplay().getHeight();
        // 以下这两句是为了保证按钮可以水平满屏
        wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
        wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;

        al_chat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(0, "CHOOSE_USER_OPERATE");
                dialog.dismiss();
            }
        });
        al_delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(1, "CHOOSE_USER_OPERATE");
                dialog.dismiss();
            }
        });
        // 设置显示位置
        dialog.onWindowAttributesChanged(wl);
        // 设置点击外围解散
        dialog.setCanceledOnTouchOutside(true);
        dialog.show();
    }

    public void showChooseDialog(Activity context, String getStr, String sendStr, String cancelStr) {
        View view = LayoutInflater.from(context).inflate(R.layout.photo_choose_dialog,
                null);
        Button getMoney = (Button) view.findViewById(R.id.btn_get);
        getMoney.setText(getStr + "");
        Button sendMOney = (Button) view.findViewById(R.id.btn_send);
        sendMOney.setText(sendStr + "");
        Button btnCancel = (Button) view.findViewById(R.id.btn_cancel);
        btnCancel.setText(cancelStr + "");
        final Dialog dialog = new Dialog(context, R.style.transparentFrameWindowStyle);
        dialog.setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        Window window = dialog.getWindow();
        // 设置显示动画
//        window.setWindowAnimations(R.style.main_menu_animstyle);
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.x = 0;
        wl.y = context.getWindowManager().getDefaultDisplay().getHeight();
        // 以下这两句是为了保证按钮可以水平满屏
        wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
        wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;

        getMoney.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(0, "QRCODE_ITEM_CHANGE");
                dialog.dismiss();
            }
        });
        sendMOney.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(1, "QRCODE_ITEM_CHANGE");
                dialog.dismiss();
            }
        });
        btnCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(2, "QRCODE_ITEM_CHANGE");
                dialog.dismiss();
            }
        });

        // 设置显示位置
        dialog.onWindowAttributesChanged(wl);
        // 设置点击外围解散
        dialog.setCanceledOnTouchOutside(true);
        dialog.show();
    }

    /**
     * 代付选择人后发送代付消息提示对话框
     */
    public void showAgentPayMsgDialog(Bundle bundle, View.OnClickListener listener) {
        setContentView(R.layout.dialog_agent_pay_msg_tip);
        //好友
        MyFriendListResponse.GetFriendsListResponseBean.FriendsesBean.FriendsBean friendsBean = bundle.getParcelable("friend_bean");
        TextView userName = (TextView) findViewById(R.id.user_name);
        TextView userId = (TextView) findViewById(R.id.user_id);
        SimpleDraweeView userIcon = (SimpleDraweeView) findViewById(R.id.user_icon);
        SimpleDraweeView userIcon1 = (SimpleDraweeView) findViewById(R.id.user_icon1);

        String realname = friendsBean.realname;
        if (TextUtils.isEmpty(realname)) {
            userName.setText("溜友");
        } else {
            userName.setText(realname);
        }
        String userid = friendsBean.nick;
        if (TextUtils.isEmpty(userid)) {
            userId.setText("");
        } else {
            userId.setText(userid);
        }
        if (TextUtils.isEmpty(friendsBean.avatar)) {
            userIcon.setVisibility(View.GONE);
            userIcon1.setVisibility(View.VISIBLE);
            FrescoUtils.loadLocalImage(R.drawable.wd_n, userIcon1);
        } else {
            if ("女".equals(friendsBean.sex) || "F".equals(friendsBean.sex)) {
                userIcon.setVisibility(View.VISIBLE);
                userIcon1.setVisibility(View.GONE);
                FrescoUtils.loadImage(friendsBean.avatar, userIcon);
            } else {
                userIcon.setVisibility(View.GONE);
                userIcon1.setVisibility(View.VISIBLE);
                FrescoUtils.loadImage(friendsBean.avatar, userIcon1);
            }
        }
        //商品
        List<String> goodsName = bundle.getStringArrayList("goodsName");
        String price = bundle.getString("order_price");

        TextView tvGoodsName = (TextView) findViewById(R.id.tv_goods_name);
        TextView tvOrderPrice = (TextView) findViewById(R.id.tv_order_price);

        String pName = "null";
        if ((goodsName != null) && (goodsName.size() > 0)) {
            pName = goodsName.get(0);
            if (goodsName.size() > 1)
                pName += "等";
        }
        tvGoodsName.setText(pName);
        tvOrderPrice.setText(TextUtils.isEmpty(price) ? "" : "¥" + DateUtil.getObjToString(Float.parseFloat(price), "0.00"));

        TextView okTv = (TextView) findViewById(R.id.ok);
        TextView cancelTv = (TextView) findViewById(R.id.cancel);
        okTv.setOnClickListener(listener);
        cancelTv.setOnClickListener(listener);
        show();
    }

    /**
     * 活动页提示弹框
     */
    public void showCampaingnSingleButtonDialog(String content, String btnStr, View.OnClickListener onClickListener) {
        setContentView(R.layout.single_btn_campaingn_dialog);
//        ImageView closeIv = (ImageView) findViewById(R.id.close);
        TextView loginTv = (TextView) findViewById(R.id.login);

        String content1, content2, content3, content4;
        content1 = content.substring(0, 12);
        content2 = content.substring(12, 25);
        content3 = content.substring(25, 39);
        content4 = content.substring(39);

        TextView contentTv1 = (TextView) findViewById(R.id.content1);
        contentTv1.setText(content1);

        TextView contentTv2 = (TextView) findViewById(R.id.content2);
        contentTv2.setText(content2);

        TextView contentTv3 = (TextView) findViewById(R.id.content3);
        contentTv3.setText(content3);

        TextView contentTv4 = (TextView) findViewById(R.id.content4);
        contentTv4.setText(content4);

        loginTv.setText(btnStr);
//        closeIv.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                dismiss();
//            }
//        });
        loginTv.setOnClickListener(onClickListener);
        show();
    }
}
